window.gameCtrl = null;
window.gDataCtrl =null;
let ACTION_RESET = 0;
let ACTION_PLAY = 1;
let ACTION_MOVE_OUT = 2;
let ACTION_MOVE_IN =3;


console.log('gDataCtrl',gDataCtrl);
function random(lower, upper) {
    return Math.floor(Math.random() * (upper - lower)) + lower;
}

function distance(p2, p1) {
    let dx = Math.abs(p2.x - p1.x);
    let  dy = Math.abs(p2.y - p1.y);
    return dis = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
}

function goldCarraybit(gold){
    let array=[
        [100000000,'N'],
        [10000000,'T'],
        [1000000,'G'],
        [100000,'M'],
        [10000,'K'],
        [1000,'B'],
    ];
    // console.log(array);
    let string ='';
    for (let i=0;i<array.length;i++){
        // console.log(i);
        let result =(gold/array[i][0]).toFixed(1);

        if(result >1){
            string= result+array[i][1];
            break;
        } else{
            string = gold;
        }
        // console.log(string,'string');

    }
    return string;
}
function setVirusColor(node,color){
    for (let i=0;i<node.children.length;i++){
        let js = node.children[i].getComponent('color');
        if(js !=null){
            node.children[i].color = color;
        }
        setVirusColor( node.children[i],color);
    }
}